﻿using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;

namespace Nine
{
    public sealed class Entity : IUpdateable, IDrawable, IEntity
    {
        #region IUpdateable Members

        #region Enabled
        private bool enabled = true;

        public bool Enabled
        {
            get { return this.enabled; }
            set
            {
                if (this.enabled != value)
                {
                    this.enabled = value;
                    if (this.EnabledChanged != null)
                        this.EnabledChanged(this, EventArgs.Empty);
                }
            }
        }

        public event EventHandler<EventArgs> EnabledChanged;
        #endregion

        #region UpdateOrder
        private int updateOrder = 0;
        
        public int UpdateOrder
        {
            get { return this.updateOrder; }
            set
            {
                if (this.updateOrder != value)
                {
                    this.updateOrder = value;
                    if (this.UpdateOrderChanged != null)
                        this.UpdateOrderChanged(this, EventArgs.Empty);
					if (this.Scene is Scene)
						(this.Scene as Scene).sort = true;
                }
            }
        }

        public event EventHandler<EventArgs> UpdateOrderChanged;
        #endregion

        #endregion

        #region IDrawable Members

        #region Visible
        private bool visible = true;

        public bool Visible
        {
            get { return this.visible; }
            set
            {
                if (this.visible != value)
                {
                    this.visible = value;
                    if (this.VisibleChanged != null)
                        this.VisibleChanged(this, EventArgs.Empty);
                }
            }
        }
        public event EventHandler<EventArgs> VisibleChanged;
        #endregion

        #region DrawOrder
        private int drawOrder = 0;

        public int DrawOrder
        {
            get { return this.drawOrder; }
            set
            {
                if (this.drawOrder != value)
                {
                    this.drawOrder = value;
                    if (this.DrawOrderChanged != null)
                        this.DrawOrderChanged(this, EventArgs.Empty);
					if (this.Scene is Scene)
						(this.Scene as Scene).sort = true;
				}
            }
        }

        public event EventHandler<EventArgs> DrawOrderChanged;
        #endregion

        #endregion

		internal bool sort = false;

		List<IDrawable> DrawnModules = new List<IDrawable>();
		List<IUpdateable> UpdatedModules = new List<IUpdateable>();

		public IScene Scene { get; internal set; }

		public void Add(Module module)
		{
			
		}
	
		public void Initialize()
		{
			
		}

		public void Update(GameTime Gt)
		{
			
		}

		public void Draw(GameTime Gt)
		{

		}
    }
}
